const name = null;
let price;
let num;
const box = [{
        name: 'javascript精粹',
        price: 138,
        num: 1

    },
    {
        name: '你不知道的javascript',
        price: 49,
        num: 2
    },
    {
        name: '小灰图解算法',
        price: 98,
        num: 3
    }
];

function sum() {
    let money = 0;
    for (let i = 0; i < box.length; i++) {
        console.log("商品" + i + ":单价为：" + box[i].price + "数量为：" + box[i].num);
        money += box[i].price * box[i].num;
    }
    console.log("总金额为：" + money + "元");
};
sum();